<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>自定义属性</title>
    <script type="text/javascript" src="../js/jquery-3.4.1.min.js"></script>
    <script>
        $(function () {
            $("a").click(function () {
                let id = $(this).attr("data-id");
                console.log("需要删除的数据的主键值为:" + id);
            });
        })
    </script>
</head>
<body>
<a href="javascript:;" data-id="2">删除</a>
</body>
</html>